home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Info-Mac 4
/
Info_Mac IV CD-ROM (Pacific HiTech Inc.)(August 1994).iso
/
Development
/
General
/
Open Prolog
/
External Predicates…
/
Sources
/
OpenPrologSpeech.p
< prev
next >
Wrap
Text File
|
1993-11-30
|
4KB
|
129 lines
{$D+} { MacsBug symbols on }
{$R+} { No range checking }
UNIT OpenPrologSpeech;
INTERFACE
USES memtypes, quickdraw, osintf, toolintf, standardFile, prlxdefinitions,
prlxLibraries, traps, gestaltEqu, speech;
PROCEDURE entrypoint(plist: prlxptr);
IMPLEMENTATION
PROCEDURE main(plist: prlxptr);
FORWARD;
PROCEDURE entrypoint(plist: prlxptr);
BEGIN
main(plist);
END;
FUNCTION speechManagerAvailable: osErr;
VAR
result: longint;
err: osErr;
BEGIN
speechManagerAvailable := noSynthFound;
{check for gestalt first}
IF TrapAvailable(_gestalt, ToolTrap)
THEN
BEGIN
err := gestalt(gestaltSpeechAttr, result);
IF err = noErr
THEN
IF (bitAnd(result, 1 {is 1<<gestaltSpeechMgrPresent} ) <> 0)
THEN speechManagerAvailable := noErr;
END;
END;
PROCEDURE main;
PROCEDURE checkOSErr(hostErrorCode: osErr; errorKind,
argumentIndex: longint; s: str255);
BEGIN
IF hostErrorCode <> noErr
THEN
begin
signalError(errorKind, argumentIndex, hostErrorCode, s, plist);
exit(main);
end;
END;
BEGIN
WITH plist^ DO
BEGIN
outcome := noErrorSucceed;
determinate := true;
CASE request OF
getPRLXInfo:
BEGIN
data[1] := 2; {number of predicates defined}
data[2] := eventsVersion;
data[3] := 0
END;
initialisepredicate:
CASE id OF
1:
BEGIN
s := 'speakAtom'; {name}
data[1] := 1; {arity}
END;
2:
BEGIN
s := 'speechBusy'; {name}
data[1] := 1; {arity}
END;
OTHERWISE
signalError(implementationError, - 1, 0,
'predicate index out of range at initialise',
plist);
END;
callpredicate:
BEGIN
WITH plist^ DO
checkOSErr(speechManagerAvailable, implementationError, 0,
'Speech Manager not Available');
CASE id OF
1:
WITH plist^ DO
BEGIN
WHILE speechBusy <> 0 DO;
checkOSErr(speakString(text(1, plist)), implementationError,
1, 'Error speaking this atom');
END;
2:
WITH plist^ DO
IF NOT returnValue(1, speechBusy, plist)
THEN outcome := noErrorFail;
OTHERWISE
signalError(implementationError, - 1, 0,
'predicate index out of range at callPredicate',
plist);
END;
END;
closepredicate:
BEGIN
CASE id OF
1: ;
2: ;
OTHERWISE
signalError(implementationError, - 1, 0,
'predicate index out of range at closePredicate',
plist);
END;
END;
OTHERWISE
signalError(implementationError, - 1, 0,
'unknown call to OpenPrologSpeech external predicate suite'
, plist);
END;
END;
END;
END.